package com.example.testdemo.recyclerview_gallery_load;

import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.util.Log;
import android.view.View;

import com.example.testdemo.R;
import com.example.testdemo.recyclerview_gallery_load.gallery.GalleryRecyclerView2;
import com.example.testdemo.recyclerview_gallery_load.gallery.ScalableCardHelper;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by zhangwenxiang on 2018/8/9.
 */

public class RecyclerViewGalleryActivity extends FragmentActivity  implements ScalableCardHelper.OnPageChangeListener {
    GalleryRecyclerView2 recyclerView;
    private MyScrollLayout myScrollLayout;
    private List<Integer> mList = new ArrayList<>();
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recyclerview_grllery_view2);
        init();
        setOnclick();
    }

    private void setOnclick(){
        //接龙层下滑监听(刷新上一级数据)
        myScrollLayout.setOnVerScrollListener(new MyScrollLayout.OnVerScrollListener() {
            @Override
            public void onVerScroll() {
                //层级页数重置
                myScrollLayout.reVisivle();
            }
        });
    }

    private void init() {
        myScrollLayout = findViewById(R.id.my_scroll_layout);
        mList.add(R.mipmap.a4);
        mList.add(R.mipmap.a5);
        mList.add(R.mipmap.a6);
        mList.add(R.mipmap.a7);
        recyclerView = findViewById(R.id.rv_list);
        recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));

        CardAdapter cardAdapter2 = new CardAdapter(mList);
        cardAdapter2.setCanLoadMore(true);//默认false
        recyclerView.setLoadMoreAdapter(cardAdapter2);

        ScalableCardHelper cardHelper = new ScalableCardHelper(this);
        cardHelper.attachToRecyclerView(recyclerView);
    }


    @Override
    public void onPageSelected(int position) {

    }
}
